/*
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/



#ifndef KEYMAZE300READER_H
#define KEYMAZE300READER_H


/*
[Date]                                          -> creation date
1=2008-12-23-17:29:13
[TP]                                            -> tracks contained in file
1=2008-12-22:19:41:18
2=2008-12-23:14:58:26
3=NONE
[2008-12-22:19:41:18]                           -> first track start time
Location=2008-12-22:19:41:18,29997,8843,            -> start time, track duration: 2999.7 sec, total distance: 8843m
SPEED=2100                                          -> max speed : 21.00km/h
1=4181533,251081                                    -> first point latittude: 41.81533 longitude:2.51081
2=4181571,251087                                    -> second point....
3=4181549,251137
...
[2008-12-23:14:58:26]                           -> second track start time
Location=2008-12-23:14:58:26,69925,8407,            -> start time....
SPEED=617                                           -> max speed
1=4182415,245290                                    -> first point...
2=4182406,245218                                    -> second point...
3=4182383,245164
...
[Location]                                      ->Waypoints
1=000,0,712,4181597,245255,                         -> track num,icon , altitude :712m, latittude: 41.81597, longitude:2.45255
2=001,0,720,4181630,245168,
...
8=NONE

*/


#include "QtCore"

#include "trackpoint.h"


#define WAYPOINT                "[Location]"
#define FILE_CREATION_DATE      "[Date]"
#define FILE_TRACKS             "[TP]"
#define TRACK                   "\\[\\d+-\\d+-\\d+:\\d+:\\d+:\\d+\\]"
#define N_POINT_REGEXP          "\\d+="
#define LAST_POINT_REGEXP       "\\d+=NONE"


#define SECONDS_IN_AN_HOUR      3600.0
#define SECONDS_IN_A_MINUTE     60.0

class Keymaze300Reader
{
public:
    Keymaze300Reader();

    void readFile(QString name);                /* read keymaze 300 txt file */
    QList< QList<TrackPoint *> >  getTracks();  /* returns tracks contained in file */
    int getNumTracks();                         /* return number of tracks in file */
private:
    void readTrack(QTextStream &in);            /* read current track */

    bool more_tracks;                           /* indicates if file contains more tracks */
    QString txt_file_name;                      /* txt file name*/
    QFile * txt_file;                           /* pointer to txt file */


    QList< QList<TrackPoint *> > lst_trks;
};

#endif // KEYMAZE300READER_H
